home *** CD-ROM | disk | FTP | other *** search
Wrap
(*************************************************** Ant Movie Catalog importation script www.antp.be/software/moviecatalog/ [Infos] Authors=kolia (kolia@mailbox.gr) Title=Cine.GR Description=Import from www.cine.gr (appends info) Site=www.cine.gr Language=EL Version=1.0 Requires=3.5.0 Comments=Based on the script made for version 3.4.0 by kolia (kolia@mailbox.gr) License=This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GetInfo=1 [Options] GetCinegrPicture=0|0|0=Do not import Picture|1=Import Picture GetSyntelestes=0|0|0=Do not import Syntelestes|1=Import Syntelestes GetCinegrComment=1|1|0=Don't import greek comment|1=You need to download another page (slower) ***************************************************) program CineGR; const ImportCINEGR = True; var MovieName: string; // CINEGR Loads and analyses page from internet (list of movies or direct hit) procedure AnalyzePageCineGr(Address: string); var Page: TStringList; begin Page := TStringList.Create; // Page.LoadFromFile('c:\testcine3.html'); Page.Text := GetPage(Address); // check for error if Pos('─σφ Γ±▌ΦτΩßφ ≤⌠∩Θ≈σ▀ß', Page.Text) > 0 then begin if Input('Cine.GR Import', 'Enter the title of the movie:'+#13#10+'(if not found Press Cancel and No to continue)', MovieName) then AnalyzePageCineGr('http://www.cine.gr/results.asp?term='+UrlEncode(MovieName)+'&type=film&image.x=16&image.y=16'); // movie list end else if Pos('>Cine.gr - Quick Search - ┴≡∩⌠σδ▌≤∞ß⌠ß<', Page.Text) > 0 then begin PickTreeClear; PickTreeAdd('Search results from cine.gr', ''); AddMoviesTitlesCineGR(Page); if PickTreeExec(Address) then AnalyzePageCineGr(Address); // refine search end else if Pos('Sorry, there is too many possible matches, please adjust your search.', Page.Text) > 0 then begin ShowMessage('Sorry, there is too many possible matches, please adjust your search.'); if Input('All Movie Import', 'Enter the title of the movie:', MovieName) then AnalyzePageCineGr('http://www.cine.gr/results.asp?term='+UrlEncode(MovieName)+'&type=film&image.x=16&image.y=16'); // direct hit end else begin AnalyzeMoviePageCineGr(Page); end; end; // Adds movie titles from search results to tree procedure AddMoviesTitlesCineGR(ResultsPage: TStringList); var Page: string; MovieTitle, MovieAddress: string; begin Page := ResultsPage.Text; // Every movie entry begins with string "film.asp?id=" while Pos('film.asp?id=', Page) > 0 do begin CutBefore(Page, 'film.asp?id='); // CutBefore(Page, 'href="http://www.cine.gr/film.asp?'); MovieAddress := 'http://www.cine.gr/film.asp?' + GetStringFromHTML(Page, 'film.asp', '?', '">'); MovieTitle := GetStringFromHTML(Page, 'film.asp', '">', '</'); MovieTitle := StringReplaceAll(MovieTitle, #13#10, ' ');//replace returns with spaces MovieTitle := StringReplaceAll(MovieTitle, ' ', ' ');//replace multiple spaces CutAfter(Page, '</'); // add movie to list // ShowMessage('MovieTitle= '+MovieTitle+' MovieAddress= '+MovieAddress); PickTreeAdd(MovieTitle, MovieAddress); end; end; // simple string procedures function StringReplaceAll(S, Old, New: string): string; begin while Pos(Old, S) > 0 do S := StringReplace(S, Old, New); Result := S; end; procedure CutAfter(var Str: string; Pattern: string); begin Str := Copy(str, Pos(Pattern, Str) + Length(Pattern), Length(Str)); end; procedure CutBefore(var Str: string; Pattern: string); begin Str := Copy(Str, Pos(Pattern, Str), Length(Str)); end; // Extracts single movie detail (like director, genre) from page function GetStringFromHTML(Page, StartTag, CutTag, EndTag: string): string; begin Result := ''; // recognition tag - if present, extract detail from page, otherwise assume detail is not present if Pos(StartTag, Page) > 0 then begin CutBefore(Page, StartTag); // optional cut tag helps finding right string in html page if Length(CutTag) > 0 then CutAfter(Page, CutTag); // movie detail copied with html tags up to end string Result := Copy(Page, 0, Pos(EndTag, Page) - 1); // remove html tags and decode html string HTMLRemoveTags(Result); HTMLDecode(Result); // ShowMessage('DEBUG: GetStringFromHTML - StartTag "'+StartTag+'", CutTag "'+CutTag+'", EndTag "'+EndTag+'", Result "'+Result+'" ___ '+Page); end; end; // Extracts movie details from page procedure AnalyzeMoviePageCineGr(MoviePage: TStringList); var Page, Page1, Value, Value2, FullValue, Perigrafh: string; begin Page := MoviePage.Text; { //Cine.gr URL Import if Length(MovieAddress) > 0 then begin SetField(fieldComments, GetField(fieldComments)+'Cine.gr URL:('+MovieAddress+')'); end; } //Cinegr Picture if GetOption('GetCinegrPicture') = 1 then begin Value := GetStringFromHTML(Page, 'FilmImages', 'FilmImages/', '"'); Value := 'http://www.cine.gr/FilmImages/'+Value; if Length(Value) > 0 then begin GetPicture(Value); end; end; //╠σ⌠ß÷±ß≤∞▌φ∩≥ ╘▀⌠δ∩≥ Value := GetStringFromHTML(Page, '- ╠σ⌠ß÷±ß≤∞▌φ∩≥ ╘▀⌠δ∩≥:', '"><b>', '</b>'); if Length(Value) > 0 then begin SetField(fieldTranslatedTitle, GetField(fieldTranslatedTitle)+' ['+Value+']'); end; //╒≡ⁿ⌠Θ⌠δ∩≥: Value := GetStringFromHTML(Page, '╒≡ⁿ⌠Θ⌠δ∩≥:', '">', '</font>'); if Length(Value) > 0 then begin Value := StringReplace(Value, #13#10, ' ');//replace returns with spaces SetField(fieldDescription, '╒≡ⁿ⌠Θ⌠δ∩≥: '+Value+#13#10+#13#10+GetField(fieldDescription)); end; //╨±σ∞Θ▌±ß ≤⌠τφ ┼δδ▄Σß Value := GetStringFromHTML(Page, '╨±σ∞Θ▌±ß ≤⌠τφ ┼δδ▄Σß:', '">', '</a>'); if Length(Value) > 0 then begin SetField(fieldDescription, '╨±σ∞Θ▌±ß ≤⌠τφ ┼δδ▄Σß: '+Value+#13#10+#13#10+GetField(fieldDescription)); end; //╙⌡φ⌠σδσ≤⌠▌≥ if GetOption('GetSyntelestes') = 1 then begin if Pos('">╙⌡φ⌠σδσ≤⌠▌≥ :', Page) > 0 then begin Page1 := Copy(Page, Pos('╙⌡φ⌠σδσ≤⌠▌≥ :', Page), Length(Page));//gia na mhn alazei to page //CutBefore(Page, '╙⌡φ⌠σδσ≤⌠▌≥ :'); //CutAfter(Page, '╨σ±Θ≤≤ⁿ⌠σ±∩Θ ╙⌡φ⌠σδσ≤⌠▌≥...'); while Pos('people.asp?name=', Page1) > 0 do begin CutBefore(Page1, 'people.asp?name='); //Recognition Tag //CutBefore(Page1, '">');//Start Tag Page1 := Copy(Page1, Pos('">', Page1) + 2, Length(Page1));//copy after the string Value := Copy(Page1, 0, Pos('</', Page1) - 1); Page1 := Copy(Page1, Pos('>....', Page1) + 5, Length(Page1));//copy after the string Perigrafh := Copy(Page1, 0, Pos('</', Page1) - 1); case Perigrafh of '╟Φ∩≡∩Θⁿ≥': begin Page1 := Copy(Page1, Pos('>....', Page1) + 5, Length(Page1));//copy after the string Value2 := Copy(Page1, 0, Pos('</', Page1) - 1); if FullValue <> '' then FullValue := FullValue + #13#10; FullValue := FullValue+Value+' ... '+Value2; // remove html tags and decode html string HTMLRemoveTags(FullValue); HTMLDecode(FullValue); SetField(fieldActors, FullValue); end; '╙Ωτφ∩Φσ⌠τ≥': begin SetField(fieldDirector, Value); end; '╙σφß±Θ∩π±▄÷∩≥': begin SetField(fieldProducer, Value+' (╙σφß±Θ∩π±▄÷∩≥)'); end; end; end; end; end; //╒≡ⁿΦσ≤τ & ╨ß±ßδσΘ≡ⁿ∞σφß (╘σδσ⌡⌠ß▀∩ πΘß⌠▀ ßδδ▄µσΘ ⌠∩ Page) if GetOption('GetCinegrComment') = 1 then begin Value := GetStringFromHTML(Page, '╒≡ⁿΦσ≤τ & ╨ß±ßδσΘ≡ⁿ∞σφß', '<a href="', '">'); if Length(Value) > 0 then begin Value := Copy(Value, 0, Length(Value) - 1) + '2';//always go to page=2 Value := StringReplaceAll(Value, '&', '&'); Value := 'http://www.cine.gr/'+Value; Page := GetPage(Value); if Pos('╨δ∩Ω▐:', Page) > 0 then begin CutBefore(Page, '╨δ∩Ω▐:'); CutBefore(Page, '<font'); // CutBefore(Page, '<BR>'); //den htan se ola etsi :( // CutBefore(Page, '<br>'); // movie detail copied with html tags up to end string Value := Copy(Page, 0, Pos('</font', Page) - 1);//alla3a to string se '</font' apo '</' // Value := GetStringFromHTML(Page, '╨δ∩Ω▐:', '<BR>', '</'); Value := StringReplaceAll(Value, #13#10, ' '); Value := StringReplaceAll(Value, '…', '...'); Value := StringReplaceAll(Value, '<br>', #13#10); Value := StringReplaceAll(Value, '<BR>', #13#10); Value := StringReplaceAll(Value, '</p>', #13#10 #13#10); Value := StringReplaceAll(Value, '</P>', #13#10 #13#10); Value := StringReplaceAll(Value, ' ', ' '); Value := StringReplaceAll(Value, #13#10+' ', #13#10); Value := StringReplaceAll(Value, '╢', 'ó'); Value := StringReplaceAll(Value, '–', '-'); Value := StringReplaceAll(Value, '’', #39); Value := StringReplaceAll(Value, '“', #34); Value := StringReplaceAll(Value, '”', #34); // remove html tags and decode html string HTMLRemoveTags(Value); HTMLDecode(Value); if Length(Value) > 0 then begin SetField(fieldDescription, '╨δ∩Ω▐:'+#13#10+Value+#13#10+#13#10+GetField(fieldDescription)); end; end; end; end; end; begin if CheckVersion(3,5,0) then begin MovieName := GetField(fieldTranslatedTitle); if (MovieName = '') then MovieName := GetField(fieldOriginalTitle); if MovieName = '' then if not Input('IMDb Import', 'Enter the title of the movie:', MovieName) then Exit; if ImportCINEGR then begin if Pos('[', MovieName) > 0 then begin MovieName := Copy(MovieName, 0, Pos('[', MovieName) - 2); SetField(fieldTranslatedTitle,MovieName);//8a mpoyn pali apo to cine gr end; if Pos('(', MovieName) > 0 then MovieName := Copy(MovieName, 0, Pos('(', MovieName) - 2); AnalyzePageCineGr('http://www.cine.gr/results.asp?term='+UrlEncode(MovieName)+'&type=film&image.x=16&image.y=16'); end; // DisplayResults; end else ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)'); end.